package com.umgsai.thread.thread22;

public class NewPrintString implements Runnable {
	private boolean isContinuePrint = true;
    public boolean isContinuePrint() {
        return isContinuePrint;
    }
    public void setContinuePrint(boolean isContinuePrint) {
        this.isContinuePrint = isContinuePrint;
    }
    public void printStringMethod() {
        try {
            while (isContinuePrint) {
                System.out.println("printStringMethod is running...threadName=" + Thread.currentThread().getName());
                Thread.sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    @Override
    public void run() {
        printStringMethod();
    }

    public static void main(String[] args) throws InterruptedException {
    	NewPrintString printString = new NewPrintString();
        new Thread(printString).start();
        Thread.sleep(5000);
        System.out.println("停止线程...");
        printString.setContinuePrint(false);
    }
}
